<template>
  <view class="normal-login-container">

    <view class="item-wrap" style="margin-bottom: 0">
      <view class="lineBottom10">
        <uni-section title="基础信息" type="line"/>
      </view>

      <view style="margin: 8rpx 20rpx 8rpx 20rpx">
        <uni-forms ref="ruleForm" :rules="rules" :model="ruleForm" labelWidth="auto">
          <uni-forms-item label="客户名称:">
            <text>{{ ruleForm.customerName || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="合同禀议编号:">
            <text>{{ ruleForm.contractNo || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="采购禀议编号:">
            <text>{{ ruleForm.purchaseNo || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆产权:">
            <text>{{ ruleForm.propertyRightName || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆归属:">
            <text>{{ ruleForm.ascription || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆运营:">
            <text>{{ ruleForm.operationsName || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆大区:">
            <text>{{ ruleForm.region || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车架号:">
            <text>{{ ruleForm.vinNo || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车牌号:">
            <text>{{ ruleForm.carNo || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="租赁合同日期:">
            <text>{{ `${ruleForm.leaseStartTime || '-'}~${ruleForm.leaseEndTime || '-'}` }}</text>
          </uni-forms-item>

          <uni-forms-item label="租赁台数:">
            <text>{{ ruleForm.leaseNum || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆行驶里程:" name="travelMeligile"
                          :required="boole">
            <text class="travelMeligile"/>
            <uni-easyinput v-if="boole" v-model="ruleForm.travelMeligile"
                           @blur="handleBlur(ruleForm.travelMeligile)"
                           placeholder="请输入车辆行驶里程"/>
            <text v-else>{{ ruleForm.travelMeligile || '-'}}</text>
          </uni-forms-item>

          <view v-if="boole" style="width: 100%;height: 15rpx" />

          <uni-forms-item label="注册日期:">
            <text>{{ ruleForm.registerTime || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="处理人:">
            <text>{{ ruleForm.processedByName || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="处理时间:">
            <text>{{ ruleForm.processedByTime || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="工单创建时间:">
            <text>{{ ruleForm.workCreateTime || '-' }}</text>
          </uni-forms-item>


        </uni-forms>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'basicInfo',//基础信息
  props: {
    value: {
      type: Object,
      default: {}
    },
    boole: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    ruleForm: {
      get() {
        let that = this
        const proxy = new Proxy(that.value, {
          get(target, key) {
            return Reflect.get(target, key)
          },
          set(target, key, value) {
            that.$emit('input', {...target, [key]: value})
            return true
          }
        })
        return proxy
      }
    },
  },
  watch: {},
  data() {
    return {
      rules: {
        travelMeligile: {
          rules: [
            {required: true, errorMessage: "请输入车辆行驶里程", validateTrigger: 'blur'},
          ],
        }
      }
    };
  },
  created() {
  },
  mounted() {
  },
  methods: {
    handleBlur(val) {
      let msg =  /^[1-9]\d*$/;
      if (!msg.test(val)) {
        this.ruleForm.travelMeligile = ""
      } else {
        this.ruleForm.travelMeligile = val
      }
    },

    handleEffect() {
      return new Promise((resolve, reject) => {
        this.$refs.ruleForm.validate().then(res => {
          resolve();
        }).catch(err => {
          let key = ".flex-col" + ">>>" + "." + err[0].key;
          reject(key);
        })
      });
    },


  },
};
</script>

<style lang="scss" scoped>
.car-wrap {
  display: flex;
  flex-direction: column;
  padding: 20rpx 20rpx 20rpx 0;
  border: 1px solid #dadada;
  margin: 10rpx 20rpx;
  border-radius: 8rpx;

}


</style>


